package com.schedule.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {
    public static final Integer CODE_SUCCESS = 1;
    public static final Integer CODE_ERROR = 0;
    private Integer code;
    private String message;
    private T data;
    public static <T> Result<T> success() {
        Result<T> result = new Result<>();
        result.message = "success";
        result.code = CODE_SUCCESS;
        return result;
    }

    public static <T> Result<T> success(T object) {
        Result<T> result = new Result<>();
        result.code = CODE_SUCCESS;
        result.message = "success";
        result.data = object;
        return result;
    }

    public static <T> Result<T> error(String msg) {
        Result<T> result = new Result<>();
        result.code = CODE_ERROR;
        result.message = msg;
        return result;
    }
}
